<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加进思用户</title>
    <script src="/jquery/jquery-3.2.1.min.js"></script>
    <script src="/layui/layui.js"></script>
    <link rel="stylesheet" href="/layui/css/layui.css"/>
    <style>
        .headerCenter{
            margin-top: 10px;
            margin-left: 20px;
            width: 100%;
        }
        .backColor{
            background-color: #F1F1F1;
        }
        .btnRight{
            float: right;
        }
        #test1{
            margin-left: 110px;
            margin-top: 30px;
        }
        .headUpload{
            margin-top: 5%;
        }
        .headImg{
            margin:0 auto;
            width:80px;
            height:80px;
            border-radius:50%;
            overflow:hidden;
            margin-right: 228px;
        }
        .btn{
            position: absolute;
            bottom: 140px;
            right: 220px;
        }
        #graduation{
            display: none;
        }
    </style>
</head>
<body>
    <div class="layui-row" >
        <div class="layui-col-md11">
            <div class="layui-card headerCenter">
                <div class="layui-card-header backColor">
                    添加进思用户
                    <div class="btnRight" style="margin-bottom: 10px">
                        <button onclick="refresh()" type="button" class="layui-btn layui-btn layui-btn-sm">
                            <i class="layui-icon layui-icon-refresh-1"></i>
                            刷新
                        </button>
                        <button type="button" class="layui-btn layui-btn layui-btn-sm">
                            <i class="layui-icon layui-icon-return"></i>
                            返回
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-row" >
        <div class="layui-col-md1"></div>
        <form class="layui-form" action="">
            <div class="layui-col-md5 ">
                <div class="layui-form-item ">
                    <label class="layui-form-label fontsize" >用户账户：</label>
                    <div class="layui-input-inline" style="margin-right: -30px; padding-right: -30px">
                        <input type="text" name="account" required lay-verify="required"  autocomplete="off" class="layui-input inp">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label fontsize" >用户昵称：</label>
                    <div class="layui-input-inline" style="margin-right: -30px; padding-right: -30px">
                        <input type="text" name="nickname" required lay-verify="required"  autocomplete="off" class="layui-input inp">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label fontsize" >用户学号：</label>
                    <div class="layui-input-inline" style="margin-right: -30px; padding-right: -30px">
                        <input type="text" name="userCode" required lay-verify="required"  autocomplete="off" class="layui-input inp">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label fontsize" >个性签名：</label>
                    <div class="layui-input-inline" style="margin-right: -30px; padding-right: -30px">
                        <input type="text" name="freestyle" required lay-verify="required"  autocomplete="off" class="layui-input inp">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label fontsize" >手机号：</label>
                    <div class="layui-input-inline" style="margin-right: -30px; padding-right: -30px">
                        <input type="text" name="phone" required lay-verify="required"  autocomplete="off" class="layui-input inp">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label fontsize" >性别：</label>
                    <div class="layui-input-block">
                        <input type="radio" lay-filter="sex" name="sex" value="0" title="保密" checked>
                        <input type="radio" lay-filter="sex" name="sex" value="1" title="男">
                        <input type="radio" lay-filter="sex" name="sex" value="2" title="女">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label fontsize" >介绍：</label>
                    <div class="layui-input-inline" style="margin-right: -30px; padding-right: -30px">
                        <input type="text" name="remarks" required lay-verify="required"  autocomplete="off" class="layui-input inp">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label fontsize" >求职意向：</label>
                    <div class="layui-input-inline" style="margin-right: -30px; padding-right: -30px">
                        <input type="text" name="intention" required lay-verify="required"  autocomplete="off" class="layui-input inp">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label fontsize" >出生日期：</label>
                    <div class="layui-input-inline" style="margin-right: -30px; padding-right: -30px">
                        <input type="text" id="birthDate" name="birthDate" required lay-verify="required"  autocomplete="off" class="layui-input inp">
                    </div>
                </div>
            </div>
            <div class="layui-col-md3 ">
                <div class="layui-form-item">
                    <label class="layui-form-label fontsize" >所学专业：</label>
                    <div class="layui-input-inline" style="margin-right: -30px; padding-right: -30px">
                        <input type="text" name="profession" required lay-verify="required"  autocomplete="off" class="layui-input inp">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label fontsize" >学习内容：</label>
                    <div class="layui-input-inline" style="margin-right: -30px; padding-right: -30px">
                        <input type="text" name="studyContent" required lay-verify="required"  autocomplete="off" class="layui-input inp">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label fontsize" >量化积分：</label>
                    <div class="layui-input-inline" style="margin-right: -30px; padding-right: -30px">
                        <input type="text" name="integration" required lay-verify="required"  autocomplete="off" class="layui-input inp">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label fontsize" >邮箱：</label>
                    <div class="layui-input-inline" style="margin-right: -30px; padding-right: -30px">
                        <input type="text" name="email" required lay-verify="required"  autocomplete="off" class="layui-input inp">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label fontsize" >身份证号：</label>
                    <div class="layui-input-inline" style="margin-right: -30px; padding-right: -30px">
                        <input type="text" name="idCard" required lay-verify="required"  autocomplete="off" class="layui-input inp">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label fontsize" >是否毕业：</label>
                    <div class="layui-input-block">
                        <input type="radio" lay-filter="type" name="type" value="3" title="是">
                        <input type="radio" lay-filter="type" name="type" value="2" title="否" checked>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label fontsize" >入学时间：</label>
                    <div class="layui-input-inline" style="margin-right: -30px; padding-right: -30px">
                        <input type="text" name="entranceDate" id="entranceDate" required lay-verify="required"  autocomplete="off" class="layui-input inp">
                    </div>
                </div>
                <div class="layui-form-item" id="graduation" >
                    <label class="layui-form-label fontsize" >毕业时间：</label>
                    <div class="layui-input-inline" style="margin-right: -30px; padding-right: -30px">
                        <input type="text" name="graduationDate" id="graduationDate"  autocomplete="off" class="layui-input inp">
                    </div>
                </div>
            </div>
            <div class="headUpload">
                <div class="headImg" id="headImg">

                </div>
                <button type="button" class="layui-btn" id="test1">
                    <i class="layui-icon">&#xe67c;</i>上传头像
                </button>
                <input type="hidden" name="avatarUrl"/>
            </div>
            <div class="btn">
                <button id="imgUpload" type="button" class="layui-btn layui-btn-sm layui-btn-normal">提交</button>
                <button style="display: none" id="sub" lay-submit lay-filter="formDemo" type="button">提交</button>
                <button onclick="cancel()" class="layui-btn layui-btn-sm layui-btn-warm">取消</button>
            </div>
            <input type="hidden" name="createId"/>
        </form>
        <div class="layui-col-md1"></div>
    </div>
</body>
    <script>
        var form;
        var $;
        var layer;
        var upload;
        var laydate;
        layui.use(['laydate','form','jquery','layer','upload'],function() {
            form = layui.form;
            laydate = layui.laydate;
            $ = layui.jquery;
            table = layui.table;
            layer = layui.layer;
            upload = layui.upload;
            //出生日期
            laydate.render({
                elem:'#birthDate',
                type:'datetime'
            });
            //入学时间
            laydate.render({
                elem:'#entranceDate',
                type:'datetime'
            });
            //毕业时间
            laydate.render({
                elem:'#graduationDate',
                type:'datetime'
            });

            form.on('radio(sex)',function(data){

            });
            form.on('radio(type)',function(data){
                if(data.value == 3){
                    $('#graduation').css('display','block');
                }else{
                    $('#graduation').css('display','none');
                }
            });

            var user = JSON.parse(localStorage.getItem('user'));
            $('input[name = createId]').val(user.userId);
            upload.render({
                elem: '#test1',
                url: '/Upload/upload',
                accept: 'file',
                field:'file',
                bindAction:'#imgUpload',
                auto:false,
                size: 1000,
                multiple: true,
                number: 9,
                choose:function (obj) {
                    var files = obj.pushFile();
                    obj.preview(function(index, file, result){
                        $('#headImg').append("<img src="+result+" id='avatarUrl' width='80px'/>");
                    });
                },
                done: function(res){
                    console.log(res.data);
                    $('input[name = avatarUrl]').val(res.data);
                    $('#sub').click();
                }
            });

            form.on('submit(formDemo)',function (data) {
                $.ajax({
                   url:'/UserList/addBeforeUser',
                   data:data.field,
                   dataType:'json',
                   success:function (data) {
                       if(data.data){
                           layer.msg("添加成功");
                           parent.$('#quickEntry').val('用户列表');
                           parent.quickEntry();
                       }else{
                           layer.msg("添加失败");
                       }
                   }
                });
            })
        });
    </script>
</html>